package com.example.dbmysql.service.impl;

import com.example.dbmysql.mapper.channelMapper;
import com.example.dbmysql.pojo.Channel;
import com.example.dbmysql.service.channelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class channelServiceImpl implements channelService {

    @Autowired
    private channelMapper channelMapper;

    @Override
    public void add(Channel channel) {
        channelMapper.add(channel);
    }

    @Override
    public Channel selectByRoomid(String channelId) {
        return channelMapper.selectByRoomid(channelId);
    }

    @Override
    public List<Channel> selectAll() {

        return    channelMapper.selectAll();
    }

    @Override
    public void update(Channel channel) {
        channel.setUpdateTimer(LocalDateTime.now());

        channelMapper.update(channel);
    }

    @Override
    public void delById(Integer id) {
        channelMapper.delByid(id);
    }

    @Override
    public Channel getById(Integer id) {
        return channelMapper.getById(id);
    }
}
